---* 蕾拉 大招
---* 治疗小球 优先弹没有弹过的英雄  都弹过则选择当前血量最少的
---* 治疗小球为子弹
---* 以当前治疗目标范围内寻找下一个弹射目标或者目标已死亡 没有则技能终止
---@class SkillEffect52100:BaseSkillEffect
SkillEffect52100 = ClientFight.CreateClass("SkillEffect52100",ClientFight.BaseSkillEffect)
local t = SkillEffect52100
function t:prepareSkill(skill,position)
    return false
end
--- 触发自己能 这里重新找目标 如果没有就此结束
---@param parentSkill FightUsingSkill
---@param target Fighter
---@param triggerSkill FightUsingSkill
function t:triggerSkill( parentSkill, target, triggerSkill)
    local fight = parentSkill.fight
    local fighter = parentSkill.fighter
    local triggerSkillBean = triggerSkill.skill.skillBean


    -- 找这个技能系列从来没有打过的目标
    local targets = SkillManager.selectAttackTargets(fight, fighter, triggerSkill.skill,
            triggerSkillBean.f_TargetRange, triggerSkillBean.f_Target, AttackUtils.getAttackRadius(fighter, triggerSkill.skill),
            AttackUtils.getAttackShape(fighter, triggerSkill.skill), parentSkill.target.position, triggerSkillBean.f_TagActivate,
            SkillManager.getRootSkill(triggerSkill).attackedTargets);
    if (#targets > 0) then
        target = targets.get(fight:random(table.getn(targets)));
    else
        --找上一次弹跳没有打过的目标
        targets = SkillManager.selectAttackTargets(fight, fighter, triggerSkill.skill,
                triggerSkillBean.f_TargetRange, triggerSkillBean.f_Target, AttackUtils.getAttackRadius(fighter, triggerSkill.skill),
                AttackUtils.getAttackShape(fighter, triggerSkill.skill), parentSkill.target.position, triggerSkillBean.f_TagActivate,
                parentSkill.getAttackedTargets);

        if ( #targets > 0) then
            target = targets[fight:random(#targets)]
        else
            -- 如果没有目标
            --fightDamageManager.finishSkill(skill, true);
            SkillRoleMgr.savePathFile( string.format("[%s][SKILL]蕾拉大招%s没有找到目标,停止释放",
            fight.frame, triggerSkillBean.f_SkillID
            ));
            return SkillEffectResult.New(true,false);
        end
    end
    ---@type Fighter
    local skillStartFighter;
    if (parentSkill.target.fighterId == fighter.fighterId) then
        skillStartFighter = fighter;
    else
        skillStartFighter = parentSkill.target
    end

    triggerSkill.target = target
    triggerSkill.startPosition = parentSkill.position
    triggerSkill.targetPosition = target.position
    triggerSkill.attackedTargets[target.fighterId] = true

    parentSkill.excludes[target.fighterId] = true
    SkillManager.getRootSkill(parentSkill).attackedTargets[parentSkill.target.fighterId] = true
    parentSkill.attackedTargets[parentSkill.target.fighterId] = true
    local frameInfo = ReportManager.flyToJsonString(fight, skillStartFighter, target, triggerSkill)
    table.insert(fight.actions, frameInfo);
    FightManager.playActions(frameInfo,triggerSkill)
    SkillManager.addSkill(fight, triggerSkill);

    --开始释放技能
    SkillManager.prepareSkill(triggerSkill, parentSkill.position);

    --子技能加速
    if (parentSkill.frame < parentSkill.skipFrame) then
        triggerSkill.skipFrame = parentSkill.skipFrame - parentSkill.frame
    end
    local logTarget = target;
    SkillRoleMgr.savePathFile( string.format("[%s][SKILL]蕾拉大招%s(%s)对%s(%s)攻击，触发子技能%s,技能起始坐标%s,目标坐标%s",
    fight.frame, fighter.fighterId, fighter.position, logTarget.fighterId,
    logTarget.position, triggerSkillBean.f_SkillID, triggerSkill.startPosition,
    triggerSkill.targetPosition
    ));
    return SkillEffectResult.New(true,true);
end
function t:attack( skill, target)
    return false;
end


function t:releaseSkill( skill)
    return false;
end

function t:finishSkill( skill, breakin)
    return false;
end
t.New()